package com.sample.service.impl;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.sample.dto.SampleTableDto;
import com.sample.entity.SampleTable;
import com.sample.mapper.SampleTableMapper;
import com.sample.service.SampleTableService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author vector4wang
 * @version ${cfg.version}
 * @since 2023-10-18
 */
@Service
public class SampleTableServiceImp extends ServiceImpl<SampleTableMapper, SampleTable> implements SampleTableService {

    @Value("${test:dir/}#{T(cn.hutool.core.date.DateUtil).format(T(cn.hutool.core.date.DateUtil).date(),T(cn.hutool.core.date.DatePattern).PURE_DATETIME_PATTERN)}")
    private String test;

    @Override
    public boolean saveEntity(SampleTable sampleTable) {
        this.saveOrUpdate(sampleTable);
        return true;
    }

    @Override
    public void delete(String id) {
        this.removeById(id);
    }

    @Override
    public IPage<SampleTable> pageList(SampleTableDto sampleTableDto) {
//        DateUtil.format(DateUtil.date(), DatePattern.PURE_DATE_PATTERN);
//        T(cn.hutool.core.date.DateUtil).format(T(cn.hutool.core.date.DateUtil).date(),T(cn.hutool.core.date.DatePattern).PURE_DATE_PATTERN)
        Page<SampleTable> sampleTablePage = new Page<>(sampleTableDto.getCurrent(), sampleTableDto.getSize());
        return page(sampleTablePage);
    }
}
